﻿using Abp.AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AVIS.OutBound.Orders.Cache
{
    [AutoMap(typeof(Order))]
    public class OrderCacheItem : OrderBase
    {
        public const string CacheName = "AvisAppOrderCache";

        #region 订单基本信息
        /// <summary>
        /// 订单Id，预订时自动生成一个
        /// </summary>
        public string OrderId { get; set; }

        /// <summary>
        /// 订单号，由Wizard接口返回（如：37378367CN5） ReservationNumber
        /// </summary>
        public string OrderNo { get; set; }

        /// <summary>
        /// 订单总金额
        /// </summary>
        public double Amount { get; set; }

        /// <summary>
        /// 货币单位
        /// </summary>
        public string CurrencyCode { get; set; }

        /// <summary>
        /// 人民币订单总金额
        /// </summary>
        public double CNAmount { get; set; }

        /// <summary>
        /// 0 门店 1 城市
        /// </summary>
        public string OrderType { get; set; }

        /// <summary>
        /// 付款类型 1:到付 2:预付
        /// </summary>
        public string PayType { get; set; }

        /// <summary>
        /// 对应上述属性 新预订 1:城市选择 2:门店选择  3:车组选择 4.附件产品选择 5.客户信息输入 6.完成
        /// 修改 0:查询  1:城市选择 2:门店选择  3:车组选择 4.附件产品选择 5.客户信息输入 6.完成
        /// </summary>
        public int OrderStep { get; set; }

        public int B2BID { get; set; }

        public int YouyouOrderID { get; set; }

        /// <summary>
        /// 是否取消
        /// </summary>
        public bool IsCancel { get; set; }

        /// <summary>
        /// 取消原因
        /// </summary>
        public string CancelReason { get; set; }

        /// <summary>
        /// 订单是否已经提交
        /// </summary>
        public bool IsSubmit { get; set; }
        #endregion

        #region 取还车信息

        /// <summary>
        /// 取车门店编号
        /// </summary>
        public string PickUpStoreCode { get; set; }

        /// <summary>
        /// 取车的区域编号
        /// </summary>
        public string PickUpRegionCode { get; set; }

        /// <summary>
        /// 取车城市编号
        /// </summary>
        public string PickUpCityCode { get; set; }

        /// <summary>
        /// 还车门店编号
        /// </summary>
        public string ReturnStoreCode { get; set; }

        /// <summary>
        /// 还车的区域编号
        /// </summary>
        public string ReturnRegionCode { get; set; }

        /// <summary>
        /// 还车城市编号
        /// </summary>
        public string ReturnCityCode { get; set; }

        /// <summary>
        /// 租期单位（一般为天）
        /// </summary>
        public string RentalUnit { get; set; }
        #endregion

        #region 优惠及协议信息

        /// <summary>
        /// Avis全球折扣号
        /// </summary>
        public string AWD { get; set; }

        ///<summary>
        ///会员卡号
        ///</summary>
        public string WizardNum { get; set; }

        ///<summary>
        ///优惠券号
        ///</summary>
        public string CouponNum { get; set; }

        ///<summary>
        ///协议号
        ///</summary>
        public string IATA { get; set; }

        /// <summary>
        /// 协议类型
        /// </summary>
        public int IATAType { get; set; }

        /// <summary>
        /// 优惠券减免金额
        /// </summary>
        public double CouponDiscountAmount { get; set; }

        /// <summary>
        /// 优惠券减免金额的币种
        /// </summary>
        public string CouponDiscountCurrencyCode { get; set; }
        #endregion

        #region 套餐及车组信息
        /// <summary>
        /// 预订车组的唯一码
        /// </summary>
        public string SIPPCode { get; set; }

        /// <summary>
        /// 套餐价格代码
        /// </summary>
        public string RateCode { get; set; }

        /// <summary>
        /// 提醒信息（请求Wizard接口会返回）
        /// </summary>
        public string WarningMessage { get; set; }
        #endregion

        #region 增值服务
        /// <summary>
        /// 客户选中的车辆装备等增值服务（结构：类型 + 数量）
        /// </summary>
        public Dictionary<string, int> Equipments
        {
            get
            {
                var dic = new Dictionary<string, int>();

                if (CarGroup != null)
                {
                    var list = CarGroup.CarEquipments.Where(e => e.Quantity > 0).ToList();
                    foreach (var e in list)
                    {
                        dic.Add(e.Type, e.Quantity);
                    }
                }

                return dic;
            }
        }

        /// <summary>
        /// 客户选中的车辆装备等增值服务的描述（需要保存到数据库）
        /// </summary>
        public string EquipmentDesc
        {
            get
            {
                if (CarGroup != null)
                {
                    var query = from e in CarGroup.CarEquipments
                                where e.Quantity > 0
                                select e.Name;
                    return string.Join(",", query);
                }
                else
                {
                    return "";
                }
            }
        }

        #endregion

        #region 客户资料及航班信息

        /// <summary>
        /// 客户的姓
        /// </summary>
        public string Surname { get; set; }

        /// <summary>
        /// 客户的名
        /// </summary>
        public string Firstname { get; set; }

        /// <summary>
        /// 客户地址
        /// </summary>
        public string Address { get; set; }

        /// <summary>
        /// 客户的邮政编码
        /// </summary>
        public string Postcode { get; set; }

        /// <summary>
        /// 客户所在城市
        /// </summary>
        public string CustomerCity { get; set; }

        /// <summary>
        /// 客户所在的国家名称
        /// </summary>
        public string CountryName { get; set; }

        /// <summary>
        /// 客户所在的国家编号
        /// </summary>
        public string CountryCode { get; set; }

        /// <summary>
        /// 客户的电话号码
        /// </summary>
        public string Telephone { get; set; }

        /// <summary>
        /// 客户的电子邮箱
        /// </summary>
        public string Email { get; set; }

        /// <summary>
        /// 常旅客协议名称
        /// </summary>
        public string FTNProgramme { get; set; }

        /// <summary>
        /// 常旅客号码
        /// </summary>
        public string FTNNumber { get; set; }

        /// <summary>
        /// 航班号
        /// </summary>
        public string FlightNumber { get; set; }

        #endregion
    }
}
